package com.epfresh.views.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.InputFilter;
import android.widget.EditText;
import android.widget.ImageView;

import com.epfresh.R;
import com.epfresh.api.utils.CashierInputFilter;
import com.epfresh.utils.FormatUtil;

/**
 * @author wangzhanghuan
 * @version 1.0
 * @date create 17-11-10
 * @Description
 */

public class EditPriceDialog extends Dialog{

    ImageView ivAdd;
    ImageView ivRemove;
    EditText ed;
    public EditPriceDialog(@NonNull Context context) {
        super(context);
    }

    public EditPriceDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected EditPriceDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_cart_add);

        ivAdd = (ImageView) findViewById(R.id.iv_add);
        ivRemove = (ImageView) findViewById(R.id.iv_remove);

        EditText ed = (EditText) findViewById(R.id.ed_price);


        ed.setSelection(ed.length());
        CashierInputFilter cashierInputFilter = new CashierInputFilter();
        cashierInputFilter.MAX_VALUE = 999999;
        ed.setFilters(new InputFilter[]{cashierInputFilter});

        ed.setFocusable(true);

    }

    public void setProductCnt(double cnt){
        ed.setText(FormatUtil.subZeroAndDot(cnt + ""));
        ed.setSelection(ed.length());
    }

    public String getProductCnt(){
        return ed.getText().toString();
    }
    
}
